package com.example.xw;

import com.example.xw.util.FileUtil;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author xiongwei_vendor
 * @date 2020/8/27 16:57
 */
public class PmdFileDeleteName {


    public void fileData() {
        try {
            File file = new File("D:\\admin\\pmd.properties");
            String fileMsg = FileUtil.readFileToString(file, "utf-8");
            String[] splMsgs = fileMsg.split("\n");
            List<String> msgStr = new ArrayList<>();
            for (int i = 0; i < splMsgs.length; i++) {
                //System.out.println(" i = " + i + "  " + splMsgs[i]);
                int tt = splMsgs[i].indexOf(".name=");
                //System.out.println("tt = " + tt);
                if (tt != -1) {
                    msgStr.add("#" + splMsgs[i].replaceAll("\\r\\n|\\r|\\n", ""));
                } else {
                    msgStr.add(splMsgs[i]);
                }
            }
            //System.out.println("====================开始查看结果===================");
            for (String s : msgStr) {
                System.out.println(s);
            }

        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
    }

}
